/**
 * 
 */
package info.noahcampbell.meter.management.plugin;

import info.noahcampbell.meter.management.reader.RraConfiguredGraph;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;


/**
 * @author Noah Campbell
 * @version 1.0
 */
public class MeterReaderEditBean {

    
    /** The template. */
    private String template;

    /**
     * @return Returns the template.
     */
    public String getTemplate() {
        return this.template;
    }

    /**
     * @param template The template to set.
     */
    public void setTemplate(String template) {
        this.template = template;
    }
    
    
    /**
     * @return templates A list of all the templates.
     */
    public List<SelectItem> getTemplates() {
        ArrayList<SelectItem> arrayList = new ArrayList<SelectItem>();
        try {
            for(RraConfiguredGraph graph : RrdManager.instance().listTemplates()) {
                SelectItem item = new SelectItem(graph, graph.getTemplate(), graph.getName());
                arrayList.add(item);
            }
        } catch (Exception e) {
            // do nothing
        }
        return arrayList;
    }

}
